import type {
  AddCashierReq,
  AddCashierRes,
  AddRuleGroupReq,
  AddRuleGroupRes,
  CashierGroupRes,
  CashierListReq,
  CashierListRes,
  DelCashierReq,
  DelCashierRes,
  DelRuleGroupReq,
  DelRuleGroupRes,
  EditCashierReq,
  EditCashierRes,
  EditRuleGroupReq,
  EditRuleGroupRes,
  GetUserInfoByTokenReq,
  GetUserInfoByTokenRes,
  getUserInfoReq,
  getUserInfoRes,
  LoginByCodeReq,
  LoginByCodeRes,
  LoginReq,
  LoginRes,
  ProfileReq,
  ProfileRes,
  RuleDetailRes,
  RuleGroupRes,
  UserCenterReq,
  UserCenterRes,
  WxLoginReq,
  WxLoginRes,
} from './types';
/**
 * 用户信息相关接口
 */
import type { CommonRes } from '@/api/common/types';
import { get, post } from '@/utils/request';

/** 获取用户信息 */
export const profile = (params?: ProfileReq) => get<ProfileRes>('/user/profile', { params });

/** 登录 */
export const login = (data: LoginReq) => post<LoginRes>('/syapi/cashier/login', { data, custom: { auth: false } });

/** 微信小程序授权登录 */
export const loginByCode = (data: LoginByCodeReq) => post<LoginByCodeRes>('/syapi/Wx/wxGetPhoneOrInfo', { data, custom: { auth: false } });

/** 退出登录 */
export const logout = () => post<CommonRes>('/user/logout');

/** 获取买家信息 */
export const getUserInfo = (params: getUserInfoReq) => get<getUserInfoRes>('/syapi/member/getUserInfo', { params });

/** 获取用户中心数据 */
export const getUserCenter = (data?: UserCenterReq) => post<UserCenterRes>('/api/user/index', { data });

/** 通过token获取用户信息 */
export const getUserInfoByToken = (data: GetUserInfoByTokenReq) => post<GetUserInfoByTokenRes>('/Syapi/Cashier/getUserInfoByToken', { data });

/** 微信多商户登录 */
export const wxLogin = (data: WxLoginReq) => post<WxLoginRes>('/syapi/Wx/wxLogin', { data, custom: { auth: false } });

/** 获取收银员列表 */
export const cashierList = (params: CashierListReq) => get<CashierListRes>('/syapi/cashier/cashierList', { params });

/** 添加收银员 */
export const addCashier = (data: AddCashierReq) => post<AddCashierRes>('/syapi/cashier/addCashier', { data });

/** 编辑收银员 */
export const editCashier = (data: EditCashierReq) => post<EditCashierRes>('/syapi/cashier/editCashier', { data });

/** 删除收银员 */
export const delCashier = (data: DelCashierReq) => post<DelCashierRes>('/syapi/cashier/delCashier', { data });

/** 获取收银员分组列表 */
export const getCashierGroup = () => get<CashierGroupRes>('/syapi/cashier/cashierGroup');

/** 获取权限组列表 */
export const getRuleGroup = () => post<RuleGroupRes>('/syapi/cashier/ruleGroup', {});

/** 添加权限组 */
export const addRuleGroup = (data: AddRuleGroupReq) => post<AddRuleGroupRes>('/syapi/cashier/ruleGroupAdd', { data });

/** 编辑权限组 */
export const editRuleGroup = (data: EditRuleGroupReq) => post<EditRuleGroupRes>('/syapi/cashier/ruleGroupEdit', { data });

/** 删除权限组 */
export const delRuleGroup = (data: DelRuleGroupReq) => post<DelRuleGroupRes>('/syapi/cashier/ruleGroupDel', { data });

/** 获取规则详情 */
export const getRuleDetail = () => post<RuleDetailRes>('/syapi/cashier/ruleGroupDetail', {});
